<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="model.*"%>
<%@ page import="dao.*"%>
<%@ page import="java.util.*"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 

<%
	request.setCharacterEncoding("utf-8");
	response.setCharacterEncoding("utf-8");
	String user = (String)session.getAttribute("user");
	if(user!=null && user.equals("1")){
		
	}else {
		response.sendRedirect("Login.jsp");
	}
%>
<%
	request.setCharacterEncoding("utf-8");
	response.setCharacterEncoding("utf-8");

	List<View> views = new ArrayList<View>();
	views = ViewDao.getViews();
	request.setAttribute("views", views);
%>
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8" />
<title>管理景点评论</title>


<jsp:include page="Header.jsp" flush="true"></jsp:include>


<!-- Latest Products -->
<div id="旅游路线">

	<div class="content-lg container">
		<div class="row margin-b-40">
			<div class="col-sm-6">
				<h2>管理评论信息</h2>
				<br>

			</div>
			<div class="col-sm-6">
				<h3>
					<br>

				</h3>
			</div>
		</div>
		<!--// end row -->

		<div class="row">

			<c:forEach var="view" items="${views}" varStatus="status">

				<div class="row margin-b-10">
					<div class="col-sm-6">
						<h3>景点名称:${view.vcname }</h3>
					</div>
					<div class="col-sm-6">
						<h3></h3>
						<p></p>
					</div>

				</div>
				<div class="row"></div>



				<table class="table table-bordered mtable2" width="100%"
					cellspacing="0">
					<thead>
						<tr>
							<th>序号</th>
							<th>游客名称</th>
							<th>评论</th>
							<th>时间</th>
							<th>状态</th>
							<th>操作</th>
						</tr>
					</thead>
		
					<tbody>
						<c:forEach var="message" items="${view.getMessages1() }"
							varStatus="status">

							<c:choose>
								<c:when test="${message.status=='0'}">
									<c:set value="未批准" var="fg" />

								</c:when>
								<c:otherwise>
									<c:set value="批准" var="fg" />

								</c:otherwise>
							</c:choose>
							<tr>
								<td>${status.index +1}</td>
								<td>${message.getTourist().name }</td>
								<td>${message.info }</td>
								<td><fmt:formatDate value="${message.time }" pattern="yyyy-MM-dd"/></td>
								<td>${fg }</td>
								<td><a
									href="javascript:if(confirm('确定要批准吗?'))location='<%=request.getContextPath()%>/MessageStatusServlet?vname=${view.name }&temail=${message.getTourist().email }&handle=1Status'">批准</a>
								&nbsp;
									<a
									href="javascript:if(confirm('确定要取消批准吗?'))location='<%=request.getContextPath()%>/MessageStatusServlet?vname=${view.name }&temail=${message.getTourist().email }&handle=0Status'">取消</a>
								</td>

							</tr>

						</c:forEach>
					</tbody>
				</table>
				<br>
				<br>
			</c:forEach>


		</div>
		<!--// end row -->
	</div>
</div>
</div>
<!-- End Latest Products -->

<jsp:include page="Footer.jsp" flush="true"></jsp:include>
<%
	String flag = "";
	String scerror = "";
	flag = (String) request.getAttribute("flag");
	System.out.println("jspflag" + flag);
	if (flag != null) {
		if (flag.equals("1")) {
			scerror = "操作成功。";
			out.print("<script language='javascript'>alert('" + scerror + "');</script>");
		}
		if (flag.equals("0")) {
			scerror = "操作失败。";
			out.print("<script language='javascript'>alert('" + scerror + "');</script>");
		}
		if (flag.equals("3")) {
			scerror = "添加成功。";
			out.print("<script language='javascript'>alert('" + scerror + "');</script>");
		}
		if (flag.equals("2")) {
			scerror = "添加失败。";
			out.print("<script language='javascript'>alert('" + scerror + "');</script>");
		}


	}
	System.out.println(scerror);
%>
<!-- Back To Top -->
<a href="javascript:void(0);" class="js-back-to-top back-to-top">Top</a>

<!-- JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
<!-- CORE PLUGINS -->
<script src="vendor/jquery.min.js" type="text/javascript"></script>
<script src="vendor/jquery-migrate.min.js" type="text/javascript"></script>
<script src="vendor/bootstrap/js/bootstrap.min.js"
	type="text/javascript"></script>
</body>
<!-- END BODY -->
</html>